﻿#region C# Libraries

using System;

#endregion

#region XNA Libraries

using Microsoft.Xna.Framework;

#endregion

#region SDK Libraries

using main.sdk.display.object2d;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using FarseerPhysics.Collision.Shapes;

#endregion

namespace main.src.game
{

    /**
     * Classe que controla um jogador
     */
    public sealed class Game_Player
    {
        #region Public Variables

        public readonly Game_Rod ParentRod = null;

        #endregion

        #region Private Variables

        private float    _RelativePosition = 0;
        private Fixture _Fixture = null;
        private Sprite   _Sprite           = new Sprite("RSC/Characters/Head");
        private const   float Ray               = 16;

        #endregion

        #region Public Members

        /**
         * Construtor do Game_Player.
         */
        public Game_Player(Game_Rod Parent, float RelativePosition)
        {
            /* Grava a vara pai */
            ParentRod = Parent;

            /* Posição Relativa. */
            _RelativePosition = RelativePosition;

            /* */
            _Fixture = FixtureFactory.AttachCircle(Ray / ParentRod.ParentTeam.ParentField.Scale, 1.0f, ParentRod.Body, Vector2.Multiply(new Vector2(0, RelativePosition), 1.0f / ParentRod.ParentTeam.ParentField.Scale));

            /* Define parametros do Sprite */
            _Sprite.OX = _Sprite.Width / 2;
            _Sprite.OY = _Sprite.Height / 2;
        }

        /**
         * Construtor do Game_Player.
         */
        public void Update(double Time)
        {
            /* Atualiza valores do jogador */
            CircleShape Shape = (CircleShape)_Fixture.Shape;
            _Sprite.Position = Vector2.Multiply(ParentRod.Body.Position + Shape.Position, ParentRod.ParentTeam.ParentField.Scale);
        }

        #endregion
    }
}